package calculadora;

/**
 *
 * @author Diego
 */
public class StackList<E> implements Stack<E>{
        private nodo<E> cab= null;
        private int cont=0;
        public void push(E item){
            nodo nuevo= new nodo();
            nuevo.dato=item;
            if (cab!=null){
                nuevo.sig=cab;
                cont++;
            }
            cab=nuevo;
        }
	   
        public E pop(){
            cont--;
            nodo<E> tmp=cab;
            E aux=tmp.dato;
            cab=cab.sig;
            tmp=null;
            return aux;
        }
	   
	public E peek(){
            E aux=cab.dato;
            return aux; 
        }
	   
	public boolean empty(){
            return size()==0;
        }
	   
	public int size(){
            return cont;
        }
}
